package com.bishi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * 字符串全排列
 */
public class 微盟 {
    static ArrayList<String> list = new ArrayList<>();
    static StringBuffer sb = new StringBuffer();
    static boolean[] used ;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        getPermutation(s);
        for(String item : list){
            System.out.println(item);
        }
    }

    public static ArrayList<String> getPermutation(String A) {
        // write code here
        if(A ==null || A.length()==0){
            return list;
        }
        char[] arr = A.toCharArray();
        used = new boolean[arr.length];
        dfs(arr, 0);
        return list;
    }

    public static void dfs(char[] arr, int depth){
        if(depth == arr.length){
            list.add(0,sb.toString());
            return;
        }
        for(int i = 0; i < arr.length; i++){
            if(used[i]) continue;
            if(i > 0 && arr[i] == arr[i-1] && !used[i-1]) continue;
            sb.append(arr[i]);
            used[i] = true;
            dfs(arr, depth+1);
            sb.deleteCharAt(sb.length()-1);
            used[i] = false;
        }
    }
}
